package org.footballmanager.pandafootball.system.controller;

import org.footballmanager.pandafootball.common.constants.Constants;
import org.footballmanager.pandafootball.system.form.impl.FootGpSearchForm;
import org.footballmanager.pandafootball.system.service.FootGpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

@Controller
@SessionAttributes("footGpSearchForm")
@RequestMapping("/foot/footGp")
public class FootGpController extends BaseController {
    /* 实体名称 */
    private static final String ENTITYNAME = "footGp";
    private static final String LISTPAGE = String.format(Constants.LISTPAGE, Constants.FOOT, ENTITYNAME);

    @Autowired
    private FootGpService footGpService;

    /**
     * 初始化
     *
     * @param map              参数
     * @param footGpSearchForm 条件参数
     */
    @ModelAttribute
    public void init(Model map, @ModelAttribute FootGpSearchForm footGpSearchForm) {
        FootGpSearchForm newFootGpSearchForm = new FootGpSearchForm();
        if (footGpSearchForm != null) {
            newFootGpSearchForm = footGpSearchForm;
        }
        map.addAttribute(String.format(Constants.FORMNAME, ENTITYNAME), newFootGpSearchForm);
    }

    @RequestMapping(value = "/search")
    public String search(Model map, @ModelAttribute FootGpSearchForm footGpSearchForm) {
        footGpService.search(ENTITYNAME, map, footGpSearchForm);
        return LISTPAGE;
    }

}
